{extend name='app' /}
{block name='title'}订单反馈{/block}

{block name="stylesheet"}
<link href="{__ADMIN__}/css/plugins/summernote/summernote-bs4.css" rel="stylesheet">
<link href="{__ADMIN__}/css/plugins/dropzone/basic.css" rel="stylesheet">
<link href="{__ADMIN__}/css/plugins/dropzone/dropzone.css" rel="stylesheet">
<style>
    .dz-image img {
        width: 100%;
    }

    .dz-size {
        display: none;
    }

</style>
{/block}

{block name="breadcrumb"}
<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-lg-10">
        <h2>订单反馈</h2>
        <ol class="breadcrumb">
            <li class="breadcrumb-item">
                <a>订单管理</a>
            </li>
            <li class="breadcrumb-item">
                <a href="{$Think.config.admin.app_host}/admin/order">订单列表</a>
            </li>
            <li class="breadcrumb-item active">
                <strong>订单反馈</strong>
            </li>
        </ol>
    </div>
</div>
{/block}

{block name="content"}
<div class="wrapper wrapper-content animated fadeInRight">

    <div class="row">
        <div class="col-lg-12">
            <div class="ibox ">
                <div class="ibox-title">
                    <h5>订单反馈</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                    </div>
                </div>

                <div class="ibox-content">
                    <form method="post" enctype="multipart/form-data" id="addForm">
                        <input type="radio" name="myradio" value="random_name" hidden checked=true/>


                        <div class="form-group row">
                            <label class="col-sm-2 control-label">项目反馈 ：</label>
                            <div class="col-sm-10">
                                <textarea class="form-control summernote" rows="6" name="content">{$order->feedback}</textarea>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>


                        <div class="form-group row">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button class="btn btn-primary" type="button" onclick="edit_goods($(this),'{$Think.config.admin.app_host}/admin/order/{$order->id}')">
                                    保存
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{/block}

{block name="script"}
<script src="{__ADMIN__}/js/plugins/summernote/summernote-bs4.js"></script>
<script src="{__ADMIN__}/js/plugins/dropzone/dropzone.js"></script>
<script type="text/javascript" src="{__ADMIN__}/js/plugins/plupload-2.1.2/js/plupload.full.min.js"></script>


<script>
    $(function () {
        $('.chosen-select').chosen({width: "100%", search_contains: true,});
    })


    function edit_goods(that, url) {
        let form_id = that.parents('form').attr('id');
        let data = new FormData(document.getElementById(form_id));

        let loading = that.ladda();

        // 加载中按钮显示
        loading.ladda('start');

        let response = post_request(url, data);
        if (response.status == 1) {
            loading.ladda('stop');
            show_swal({msg: response.msg}, function () {
                if (document.referrer) {
                    window.location.href = document.referrer;
                } else {
                    window.location.href = '{$Think.config.admin.app_host}/admin/project';
                }
            });
        } else {
            let msg = response.msg
            if (!msg) {
                msg = '系统出错了';
            }
            show_tip('提示', msg, 'error');
            // 加载中按钮隐藏
            loading.ladda('stop');
        }
    }
</script>

<script>
    $(function () {
        $('.summernote').summernote({
            height: 300,
            callbacks: {
                onImageUpload: function (files, editor, welEditable) {
                    for (var i = files.length - 1; i >= 0; i--) {
                        sendFile(files[i], this);
                    }
                    // $(document.body).addClass("modal-open");
                },
                onImageUploadError: function () {
                    // $(document.body).addClass("modal-open");
                }
            },

        });

        function sendFile(file, el) {
            var url = '{$Think.config.admin.app_host}/admin/common/file';
            var data = new FormData();
            data.append("project_detail", file); // 表单名称

            let response = post_request(url, data);
            if (response.status == 1) {
                $(el).summernote('editor.insertImage', response.data.url, response.data.path);
            } else {
                show_tip('提示', response.msg, 'error');
            }
        }
    });
</script>
{/block}
